package org.hackystat.devcathlon.ui.page.teams.manage;

import static org.junit.Assert.assertNotNull;
import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.hackystat.devcathlon.engine.test.DevcathlonTestHelper;
import org.hackystat.devcathlon.ui.DevcathlonApplication;
import org.hackystat.devcathlon.ui.page.login.LoginPage;
import org.junit.Test;

/**
 * Test classes for the TeamManageCreatePage. 
 *
 * @author John Ly
 *
 */

public class TestTeamsManageCreatePage extends DevcathlonTestHelper { 
  
  private String user = "admin@hackystat.org";
  
  /**
   * Tests the TeamManageCreate page for display information.
   * @throws Exception If there is a bug.
   */
  @Test
  public void testTeamsManageCreatePage() throws Exception {
    WicketTester tester = new WicketTester(new DevcathlonApplication());
    
    tester.startPage(TeamsManageCreatePage.class);
    tester.assertRenderedPage(LoginPage.class);    

    // Fill out the login form.
    FormTester formTester = tester.newFormTester("loginForm");
    formTester.setValue("user", user);
    formTester.setValue("password", user);
    formTester.submit();
        
    tester.assertRenderedPage(TeamsManageCreatePage.class);
    
    assertNotNull("wicket ID form found.", tester.getTagByWicketId("createTeamForm"));
    
    FormTester createForm = tester.newFormTester("createTeamForm");
    createForm.setValue("teamNameBorder:teamName", "My1stTeam");
    createForm.select("projectNameBorder:projectName", 0);
//    createForm.select("logoPath", 0);
    createForm.submit();
    
    tester.assertRenderedPage(TeamsManagePage.class);    
  }
  
  
  
}
